package com.lujieni.cloud.controller;


import com.lujieni520.cloud.dto.ResponseDTO;
import com.lujieni520.cloud.dto.UserDto;
import com.lujieni520.cloud.service.SayPortClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;


@RestController
@Slf4j
public class SayPortController {

    @Autowired
    private SayPortClientService sayPortClientService;

    @RequestMapping(value = "/say", method = RequestMethod.GET)
    public String say(){
        return sayPortClientService.say();
    }

    @RequestMapping(value = "/bye", method = RequestMethod.GET)
    public String bye() {
        return sayPortClientService.bye();
    }


    @RequestMapping(value = "/insert", method = RequestMethod.GET)
    public String insert(){
        String result = sayPortClientService.insert();
        System.out.println(result);
        return result;
    }

    @RequestMapping(value = "/usePathVariable", method = RequestMethod.GET)
    public String usePathVariable(){
        String result = sayPortClientService.usePathVariable("lujieni");
        System.out.println(result);
        return result;
    }

    @RequestMapping(value = "/getWithGeneric", method = RequestMethod.GET)
    public UserDto getWithGeneric(){
        ResponseDTO response = sayPortClientService.getWithGeneric();
        UserDto data = (UserDto)response.getData();
        return data;
    }


}
